- Author:
- Randall Britten <r.britten@auckland.ac.nz>
- Date:
- 2013-12-05 16:29:47+13:00
- Desc:
- Added ?SaveDefinitions -> True? to ?Manipulate? blocks so that CDF export works.
- Permanent Source URI:
- https://models.fieldml.org/workspace/178/rawfile/b2146c6c6b06de44ace1035d9cbcd1d68d199808/pH Homeostasis.nb
(* Content-type: application/vnd.wolfram.mathematica *)
(*** Wolfram Notebook File ***)
(* http://www.wolfram.com/nb *)
(* CreatedBy='Mathematica 9.0' *)
(*CacheID: 234*)
(* Internal cache information:
NotebookFileLineBreakTest
NotebookFileLineBreakTest
NotebookDataPosition[ 157, 7]
NotebookDataLength[ 34119, 838]
NotebookOptionsPosition[ 33011, 802]
NotebookOutlinePosition[ 33366, 818]
CellTagsIndexPosition[ 33323, 815]
WindowFrame->Normal*)
(* Beginning of Notebook Content *)
Notebook[{
Cell[BoxData[
RowBox[{
RowBox[{"initialPh", "=", "7.4"}], ";"}]], "Input",
CellChangeTimes->{{3.588028935288416*^9, 3.588028947630732*^9}}],
Cell[BoxData[
RowBox[{
RowBox[{
RowBox[{"Hmolar", "[", "initialPh_", "]"}], ":=",
SuperscriptBox["10",
RowBox[{"-", "initialPh"}]]}], ";"}]], "Input",
CellChangeTimes->{
3.588026866945672*^9, 3.588027345006266*^9, {3.588027526578341*^9,
3.588027528457705*^9}, {3.5880275950477552`*^9, 3.588027623943098*^9}, {
3.588028951319806*^9, 3.588028955827985*^9}, {3.588029035381466*^9,
3.5880290360526953`*^9}, {3.594926481999916*^9, 3.594926490448428*^9},
3.594926838297065*^9}],
Cell[BoxData[
RowBox[{
RowBox[{"initialCO2mmHg", "=", "40"}], ";"}]], "Input",
CellChangeTimes->{{3.588028961701105*^9, 3.5880289701902637`*^9}}],
Cell[BoxData[
RowBox[{
RowBox[{"co2SolubilityMilliMolarPerMmhg", "=", "0.03"}], ";"}]], "Input",
CellChangeTimes->{{3.588011381426174*^9, 3.5880113944215317`*^9}, {
3.588029074748098*^9, 3.588029092014204*^9}, {3.5951878085705967`*^9,
3.595187817348166*^9}, {3.595195044229349*^9, 3.595195045044229*^9}}],
Cell[BoxData[
RowBox[{
RowBox[{
RowBox[{"CO2molarFromMillimetresHg", "[", "CO2mmHg_", "]"}], ":=",
FractionBox[
RowBox[{"CO2mmHg", " ", "co2SolubilityMilliMolarPerMmhg"}], "1000"]}],
";"}]], "Input",
CellChangeTimes->{
3.588026852226532*^9, 3.588026943288953*^9, {3.5880275452983923`*^9,
3.58802754682507*^9}, {3.588027627063496*^9, 3.588027635999963*^9}, {
3.588028977886209*^9, 3.588029022197158*^9}, {3.588030010813973*^9,
3.5880300116060743`*^9}, {3.588032567434842*^9, 3.58803257466298*^9}, {
3.594926783617146*^9, 3.5949268167756987`*^9}, 3.594926850790475*^9, {
3.595187698996812*^9, 3.595187700100819*^9}, {3.595187735781953*^9,
3.595187736996676*^9}, 3.595187830314361*^9, 3.5951950929255323`*^9, {
3.595196728287156*^9, 3.595196740460393*^9}}],
Cell[BoxData[
RowBox[{
RowBox[{"CO2mmHgFromMolar", "[", "CO2molarParam_", "]"}], ":=",
RowBox[{"1000", " ",
FractionBox["CO2molarParam",
"co2SolubilityMilliMolarPerMmhg"]}]}]], "Input",
CellChangeTimes->{{3.595187702540475*^9, 3.59518780271523*^9},
3.595187834596815*^9, 3.59518789381619*^9, 3.595195096677342*^9}],
Cell[BoxData[
RowBox[{
RowBox[{"pKfromTextbook", "=", "6.1"}], ";"}]], "Input",
CellChangeTimes->{{3.588028556376622*^9, 3.58802856809615*^9}}],
Cell[BoxData[
RowBox[{
RowBox[{"KfromTextbook", "=",
SuperscriptBox["10",
RowBox[{"-", "pKfromTextbook"}]]}], ";"}]], "Input",
CellChangeTimes->{{3.588012103263454*^9, 3.588012122807251*^9},
3.588012563011053*^9, 3.588029064612894*^9, {3.5880300336289062`*^9,
3.588030043062311*^9}, 3.588033492664633*^9, 3.588034881261235*^9, {
3.595196055520857*^9, 3.595196079037346*^9}}],
Cell[BoxData[
RowBox[{
RowBox[{"initialCO2molar", "=",
RowBox[{"CO2molarFromMillimetresHg", "[", "initialCO2mmHg", "]"}]}],
";"}]], "Input",
CellChangeTimes->{{3.5949268814060183`*^9, 3.5949268954061327`*^9},
3.595196769712036*^9}],
Cell[BoxData[
RowBox[{
RowBox[{
RowBox[{"HCO3molar", "[",
RowBox[{"CO2molar_", ",", "pH_"}], "]"}], ":=",
RowBox[{"CO2molar", " ",
FractionBox["KfromTextbook",
SuperscriptBox["10",
RowBox[{"-", "pH"}]]]}]}], ";"}]], "Input",
CellChangeTimes->{{3.588035465787499*^9, 3.588035507516808*^9}, {
3.588035570662325*^9, 3.588035584396131*^9}, {3.5951103664645042`*^9,
3.595110425042737*^9}}],
Cell[BoxData[
RowBox[{
RowBox[{"initialHCO3molar", "=",
RowBox[{"HCO3molar", "[",
RowBox[{"initialCO2molar", ",", "initialPh"}], "]"}]}], ";"}]], "Input",
CellChangeTimes->{{3.595110431818136*^9, 3.5951104619138803`*^9}}],
Cell[BoxData[
RowBox[{
RowBox[{
RowBox[{"pCO2mmHg", "[",
RowBox[{"pH_", ",", "HCO3Molar_", ",", "K_"}], "]"}], ":=",
RowBox[{
FractionBox[
SuperscriptBox["10",
RowBox[{"-", "pH"}]], "K"],
FractionBox[
RowBox[{"1000", "HCO3Molar"}], "co2SolubilityMilliMolarPerMmhg"]}]}],
";"}]], "Input",
CellChangeTimes->{{3.588011527879652*^9, 3.588011574290142*^9}, {
3.588011605456628*^9, 3.588011648639924*^9}, {3.5880119395225277`*^9,
3.588011941657003*^9}, {3.588029099237656*^9, 3.588029102004583*^9}, {
3.588029742140643*^9, 3.588029745588648*^9}, {3.5880298638730307`*^9,
3.588029870777545*^9}, 3.595187843027348*^9, {3.595195169031292*^9,
3.5951951833292513`*^9}, {3.5951954817946367`*^9, 3.595195485858616*^9}, {
3.595196019030799*^9, 3.595196019645368*^9}}],
Cell[BoxData[
RowBox[{
RowBox[{"initialHmolar", "=",
RowBox[{"Hmolar", "[", "initialPh", "]"}]}], ";"}]], "Input",
CellChangeTimes->{{3.594926909677643*^9, 3.594926920275756*^9}}],
Cell[BoxData[
RowBox[{
RowBox[{"KbyInitial", "=",
FractionBox[
RowBox[{"initialHmolar", " ", "initialHCO3molar"}], "initialCO2molar"]}],
";"}]], "Input",
CellChangeTimes->{{3.5880276531793737`*^9, 3.5880276717256613`*^9}, {
3.588027720485572*^9, 3.588027766262341*^9}, 3.588028516161331*^9, {
3.588029040884555*^9, 3.5880290519690933`*^9}, {3.595196065996739*^9,
3.5951960746366873`*^9}}],
Cell[BoxData[
RowBox[{
RowBox[{"pKbyInitial", " ", "=", " ",
RowBox[{"-",
RowBox[{"Log10", "[", "KbyInitial", "]"}]}]}], ";"}]], "Input",
CellChangeTimes->{{3.588027774043713*^9, 3.588027798668395*^9},
3.588028524865922*^9}],
Cell[BoxData[
RowBox[{"contourPlot1", " ", "=",
RowBox[{"ContourPlot", "[",
RowBox[{
RowBox[{"pCO2mmHg", "[",
RowBox[{"pH", ",",
RowBox[{"HCO3", "/", "1000"}], ",", "KfromTextbook"}], "]"}], ",",
RowBox[{"{",
RowBox[{"pH", ",", "6.8", ",", "8"}], "}"}], ",",
RowBox[{"{",
RowBox[{"HCO3", ",", "0", ",", "100"}], "}"}], ",",
"\[IndentingNewLine]",
RowBox[{"Contours", "\[Rule]",
RowBox[{"{",
RowBox[{"20", ",", "40", ",", "80"}], "}"}]}]}], "\[IndentingNewLine]",
"]"}]}]], "Input",
CellChangeTimes->{{3.588011703454999*^9, 3.5880117174087048`*^9}, {
3.5880117501903267`*^9, 3.588011883386302*^9}, {3.588012489020569*^9,
3.588012525930511*^9}, {3.58802796882439*^9, 3.5880279848488283`*^9}, {
3.5880303452699127`*^9, 3.588030350357877*^9}, {3.5880322855350943`*^9,
3.5880322876371603`*^9}, {3.5880324327627296`*^9, 3.588032437474824*^9}, {
3.588033246047154*^9, 3.5880332502935057`*^9}, {3.595111178599168*^9,
3.595111183189722*^9}, {3.5951952311043367`*^9, 3.595195232283929*^9}, {
3.595195813715382*^9, 3.5951958144663687`*^9}}],
Cell[BoxData[
RowBox[{
RowBox[{"plot3d1", "=",
RowBox[{"Plot3D", "[",
RowBox[{
RowBox[{"pCO2mmHg", "[",
RowBox[{"pH", ",",
RowBox[{"HCO3milliMolar", "/", "1000"}], ",", "KfromTextbook"}], "]"}],
",",
RowBox[{"{",
RowBox[{"pH", ",", "6.8", ",", "8"}], "}"}], ",",
RowBox[{"{",
RowBox[{"HCO3milliMolar", ",", "0", ",", "100"}], "}"}], ",",
"\[IndentingNewLine]",
RowBox[{"Mesh", "\[Rule]", "None"}], ",", "\[IndentingNewLine]",
RowBox[{"ColorFunction", "\[Rule]", "Hue"}], ",", "\[IndentingNewLine]",
RowBox[{"ImageSize", "\[Rule]", "Full"}], ",", "\[IndentingNewLine]",
RowBox[{"PlotStyle", "\[Rule]",
RowBox[{"Directive", "[",
RowBox[{"Opacity", "[", "0.8", "]"}], "]"}]}], ",",
"\[IndentingNewLine]",
RowBox[{"AxesLabel", "\[Rule]",
RowBox[{"{",
RowBox[{"pH", ",", "HCO3", ",", "CO2"}], "}"}]}]}],
"\[IndentingNewLine]", "]"}]}], ";"}]], "Input",
CellChangeTimes->{{3.59492488658932*^9, 3.5949248956597137`*^9}, {
3.594924927011917*^9, 3.594924933402796*^9}, {3.594925079520697*^9,
3.594925080610795*^9}, {3.595111311589692*^9, 3.59511131600488*^9}, {
3.595195237968726*^9, 3.595195238763986*^9}, {3.595195454907606*^9,
3.595195456170892*^9}, {3.595197243784171*^9, 3.5951972724645348`*^9}, {
3.5951974323087273`*^9, 3.595197476947402*^9}, {3.5951977251357193`*^9,
3.5951977490919943`*^9}, {3.5951979261793947`*^9, 3.5951979340823298`*^9}, {
3.595198985823867*^9, 3.595199008286253*^9}}],
Cell[BoxData[
RowBox[{
RowBox[{
RowBox[{"J", "[",
RowBox[{"CO2_", ",", "H_", ",", "HCO3_", ",", "K_"}], "]"}], ":=",
"\[IndentingNewLine]",
RowBox[{"With", "[", "\[IndentingNewLine]",
RowBox[{
RowBox[{"{",
RowBox[{
RowBox[{"kb", "=", "1"}], ",",
RowBox[{"kf", "=", "K"}]}], "}"}], ",", "\[IndentingNewLine]",
RowBox[{
RowBox[{"kf", " ", "CO2"}], "-",
RowBox[{"kb", " ", "H", " ", "HCO3"}]}]}], "]"}]}], ";"}]], "Input",
CellChangeTimes->{{3.588018786296715*^9, 3.588018834936934*^9}, {
3.58803064993417*^9, 3.588030702244219*^9}, {3.588030736556336*^9,
3.5880307392600393`*^9}}],
Cell[BoxData[
RowBox[{
RowBox[{
RowBox[{"s2", "[",
RowBox[{
"initialHmolar_", ",", "initialCO2molar_", ",", "initialHCO3molar_", ",",
"co2source_", ",", "co2sink_", ",", "protonSource_", ",", "timeSpan_"}],
"]"}], ":=",
RowBox[{"NDSolve", "[", "\[IndentingNewLine]",
RowBox[{
RowBox[{"{", "\[IndentingNewLine]",
RowBox[{
RowBox[{
RowBox[{
RowBox[{"H", "'"}], "[", "t", "]"}], "\[Equal]",
RowBox[{
RowBox[{"J", "[",
RowBox[{
RowBox[{"CO2", "[", "t", "]"}], ",",
RowBox[{"H", "[", "t", "]"}], ",",
RowBox[{"HCO3", "[", "t", "]"}], ",", "KfromTextbook"}], "]"}],
"+", "protonSource"}]}], ",", "\[IndentingNewLine]",
RowBox[{
RowBox[{
RowBox[{"HCO3", "'"}], "[", "t", "]"}], "==",
RowBox[{"J", "[",
RowBox[{
RowBox[{"CO2", "[", "t", "]"}], ",",
RowBox[{"H", "[", "t", "]"}], ",",
RowBox[{"HCO3", "[", "t", "]"}], ",", "KfromTextbook"}], "]"}]}],
",", "\[IndentingNewLine]",
RowBox[{
RowBox[{
RowBox[{"CO2", "'"}], "[", "t", "]"}], "\[Equal]",
RowBox[{
RowBox[{"-",
RowBox[{"J", "[",
RowBox[{
RowBox[{"CO2", "[", "t", "]"}], ",",
RowBox[{"H", "[", "t", "]"}], ",",
RowBox[{"HCO3", "[", "t", "]"}], ",", "KfromTextbook"}], "]"}]}],
"+", "co2source", "-", "co2sink"}]}], ",", "\[IndentingNewLine]",
RowBox[{
RowBox[{"H", "[", "0", "]"}], "\[Equal]", "initialHmolar"}], ",",
"\[IndentingNewLine]",
RowBox[{
RowBox[{"CO2", "[", "0", "]"}], "\[Equal]", "initialCO2molar"}], ",",
"\[IndentingNewLine]",
RowBox[{
RowBox[{"HCO3", "[", "0", "]"}], "\[Equal]", "initialHCO3molar"}]}],
"\[IndentingNewLine]", "}"}], ",", "\[IndentingNewLine]",
RowBox[{"{",
RowBox[{"H", ",", "HCO3", ",", "CO2"}], "}"}], ",",
RowBox[{"{",
RowBox[{"t", ",", "0", ",", "timeSpan"}], "}"}]}], "]"}]}],
";"}]], "Input",
CellChangeTimes->{{3.588018715475564*^9, 3.5880187162902117`*^9}, {
3.588018840234191*^9, 3.588018998732294*^9}, {3.588019038114986*^9,
3.5880191392578297`*^9}, {3.58801919229058*^9, 3.5880192037189703`*^9}, {
3.5880192708295116`*^9, 3.5880193124369717`*^9}, 3.588019393691187*^9, {
3.588019780866252*^9, 3.588019781165984*^9}, {3.5880267892763033`*^9,
3.588026813484517*^9}, {3.588027037873416*^9, 3.5880270428576*^9}, {
3.588027279146137*^9, 3.588027321720139*^9}, {3.5880273575433826`*^9,
3.5880273907936583`*^9}, {3.588027420862603*^9, 3.5880274750777607`*^9}, {
3.5880280434626217`*^9, 3.5880280573032427`*^9}, {3.5880291201567917`*^9,
3.588029129520361*^9}, {3.588029918088847*^9, 3.5880299189117603`*^9}, {
3.588030715718298*^9, 3.588030723876318*^9}, {3.5949252432218523`*^9,
3.594925272156485*^9}, {3.594926658893195*^9, 3.594926659116704*^9}, {
3.5949275232173157`*^9, 3.594927529706739*^9}, {3.595112563786137*^9,
3.5951125663317823`*^9}, 3.59511261916051*^9, {3.59519834836016*^9,
3.595198350305169*^9}, {3.595201469699197*^9, 3.5952015601811447`*^9}, {
3.595201711508465*^9, 3.5952017611606083`*^9}, {3.5952019132477837`*^9,
3.5952019139824*^9}}],
Cell[BoxData[
RowBox[{"Manipulate", "[", "\[IndentingNewLine]",
RowBox[{
RowBox[{"With", "[",
RowBox[{
RowBox[{"{",
RowBox[{"s3", "=",
RowBox[{"s2", "[",
RowBox[{
RowBox[{"Hmolar", "[", "initialPh", "]"}], ",",
RowBox[{"CO2molarFromMillimetresHg", "[", "initialCO2mmHg", "]"}],
",",
RowBox[{"initialHCO3mM", "/", "1000"}], ",", "co2source", ",",
"co2sink", ",", "protonSource", ",", "timeSpan"}], "]"}]}], "}"}],
",", "\[IndentingNewLine]",
RowBox[{"{", "\[IndentingNewLine]",
RowBox[{
RowBox[{"Plot", "[",
RowBox[{
RowBox[{"Evaluate", "[",
RowBox[{
RowBox[{"-",
RowBox[{"Log10", "[",
RowBox[{"H", "[", "t", "]"}], "]"}]}], "/.", "s3"}], "]"}], ",",
RowBox[{"{",
RowBox[{"t", ",", "0", ",", "timeSpan"}], "}"}], ",",
RowBox[{"PlotRange", "\[Rule]",
RowBox[{"{",
RowBox[{
RowBox[{"{",
RowBox[{"0", ",", "timeSpan"}], "}"}], ",",
RowBox[{"{",
RowBox[{"6.8", ",", "8.0"}], "}"}]}], "}"}]}]}], "]"}], ",",
"\[IndentingNewLine]",
RowBox[{"Plot", "[",
RowBox[{
RowBox[{"Evaluate", "[", " ",
RowBox[{
RowBox[{"1000",
RowBox[{
RowBox[{"CO2", "[", "t", "]"}], "/",
"co2SolubilityMilliMolarPerMmhg"}]}], "/.", "s3"}], "]"}], ",",
RowBox[{"{",
RowBox[{"t", ",", "0", ",", "timeSpan"}], "}"}], ",",
RowBox[{"PlotRange", "\[Rule]",
RowBox[{"{",
RowBox[{
RowBox[{"{",
RowBox[{"0", ",", "timeSpan"}], "}"}], ",",
RowBox[{"{",
RowBox[{"0", ",", "120"}], "}"}]}], "}"}]}]}], "]"}], ",",
"\[IndentingNewLine]",
RowBox[{"Plot", "[",
RowBox[{
RowBox[{"Evaluate", "[",
RowBox[{
RowBox[{"1000", " ",
RowBox[{"HCO3", "[", "t", "]"}]}], "/.", "s3"}], "]"}], ",",
RowBox[{"{",
RowBox[{"t", ",", "0", ",", "timeSpan"}], "}"}], ",",
RowBox[{"PlotRange", "\[Rule]",
RowBox[{"{",
RowBox[{
RowBox[{"{",
RowBox[{"0", ",", "timeSpan"}], "}"}], ",",
RowBox[{"{",
RowBox[{"0", ",", "100"}], "}"}]}], "}"}]}]}], "]"}], ",",
"\[IndentingNewLine]",
RowBox[{"ParametricPlot", "[",
RowBox[{
RowBox[{"Evaluate", "[",
RowBox[{
RowBox[{"{",
RowBox[{
RowBox[{"-",
RowBox[{"Log10", "[",
RowBox[{"H", "[", "t", "]"}], "]"}]}], ",",
RowBox[{"1000", " ",
RowBox[{"HCO3", "[", "t", "]"}]}]}], "}"}], "/.", "s3"}], "]"}],
",",
RowBox[{"{",
RowBox[{"t", ",", "0", ",", "timeSpan"}], "}"}], ",",
RowBox[{"PlotRange", "\[Rule]",
RowBox[{"{",
RowBox[{
RowBox[{"{",
RowBox[{"6.8", ",", "8.0"}], "}"}], ",",
RowBox[{"{",
RowBox[{"0", ",", "100"}], "}"}]}], "}"}]}], ",",
RowBox[{"AspectRatio", "\[Rule]", "1"}], ",", "\[IndentingNewLine]",
RowBox[{"ColorFunction", "\[Rule]",
RowBox[{"(",
RowBox[{
RowBox[{
RowBox[{"ColorData", "[", "\"\<Rainbow\>\"", "]"}], "[", "#3",
"]"}], "&"}], ")"}]}], ",",
RowBox[{"MaxRecursion", "\[Rule]", "0"}], ",",
RowBox[{"PlotStyle", "\[Rule]", "Thick"}]}], "]"}], ",",
"\[IndentingNewLine]",
RowBox[{
RowBox[{"{", "\[IndentingNewLine]",
RowBox[{
RowBox[{"-",
RowBox[{"Log10", "[",
RowBox[{"H", "[", "timeSpan", "]"}], "]"}]}], ",",
"\[IndentingNewLine]",
RowBox[{"1000",
RowBox[{"HCO3", "[", "timeSpan", "]"}]}]}], "\[IndentingNewLine]",
"}"}], "/.", "s3"}]}], "\[IndentingNewLine]", "}"}]}], "]"}], ",",
"\[IndentingNewLine]",
RowBox[{"{",
RowBox[{
RowBox[{"{",
RowBox[{"initialPh", ",", "7.4"}], "}"}], ",", " ", "7.0", ",", " ",
"7.8"}], "}"}], ",", "\[IndentingNewLine]",
RowBox[{"{",
RowBox[{
RowBox[{"{",
RowBox[{"initialCO2mmHg", ",", "40"}], "}"}], ",", " ", "20", ",", " ",
"80"}], "}"}], ",", "\[IndentingNewLine]",
RowBox[{"{",
RowBox[{
RowBox[{"{",
RowBox[{"initialHCO3mM", ",",
RowBox[{"1000", "initialHCO3molar"}]}], "}"}], ",", " ", "0", ",", " ",
"100"}], "}"}], ",", "\[IndentingNewLine]",
RowBox[{"{",
RowBox[{"co2source", ",", "0", ",",
RowBox[{"10", " ",
SuperscriptBox["10",
RowBox[{"-", "6"}]]}]}], "}"}], ",", "\[IndentingNewLine]",
RowBox[{"{",
RowBox[{"co2sink", ",", "0", ",",
RowBox[{"10", " ",
SuperscriptBox["10",
RowBox[{"-", "6"}]]}]}], "}"}], ",", "\[IndentingNewLine]",
RowBox[{"{",
RowBox[{"protonSource", ",", "0", ",",
RowBox[{"2", " ",
SuperscriptBox["10",
RowBox[{"-", "9"}]]}]}], "}"}], ",", "\[IndentingNewLine]",
RowBox[{"{",
RowBox[{"timeSpan", ",", " ", "100", ",", "1000"}], "}"}], ",",
"\[IndentingNewLine]",
RowBox[{"ContentSize", "\[Rule]", "400"}], ",", "\[IndentingNewLine]",
RowBox[{"SaveDefinitions", "\[Rule]", "True"}]}], "\[IndentingNewLine]",
"]"}]], "Input",
CellChangeTimes->{{3.5880193595553627`*^9, 3.588019419808826*^9}, {
3.588019586814019*^9, 3.588019640555421*^9}, {3.588019692218618*^9,
3.588019694042286*^9}, {3.588019750250059*^9, 3.588019813783346*^9}, {
3.5880299242152042`*^9, 3.5880299245991173`*^9}, 3.588033297268264*^9, {
3.594925306922489*^9, 3.59492536201825*^9}, {3.59492539337101*^9,
3.5949253975291853`*^9}, {3.594926391490402*^9, 3.594926459456328*^9}, {
3.594926522813073*^9, 3.5949265682890987`*^9}, 3.594926628374145*^9, {
3.59492666306857*^9, 3.594926668628605*^9}, {3.594926733742449*^9,
3.5949267619144793`*^9}, {3.594927034677702*^9, 3.594927065614521*^9}, {
3.594927117626059*^9, 3.5949271438758173`*^9}, {3.594927183921032*^9,
3.5949271912485037`*^9}, {3.594927384621303*^9, 3.594927469386701*^9}, {
3.5949275163471622`*^9, 3.594927540930584*^9}, {3.5949400867383823`*^9,
3.594940134483419*^9}, {3.594940185087165*^9, 3.5949402150775623`*^9}, {
3.594940248772423*^9, 3.594940323642118*^9}, {3.594940361721167*^9,
3.594940415730435*^9}, {3.594940469056479*^9, 3.594940470191268*^9}, {
3.5949405389347*^9, 3.594940539366806*^9}, {3.594940594550515*^9,
3.594940598779985*^9}, {3.594942331283164*^9, 3.594942354900467*^9},
3.594943631098691*^9, {3.595109709129572*^9, 3.59510970987253*^9}, {
3.5951097892002773`*^9, 3.595109807070904*^9}, {3.5951099593207006`*^9,
3.595109960739943*^9}, {3.5951128201983347`*^9, 3.595112946033599*^9}, {
3.59511298201234*^9, 3.595113019398241*^9}, {3.595113077408825*^9,
3.5951130803519287`*^9}, {3.5951868878303137`*^9,
3.5951868910971527`*^9}, {3.595186930265133*^9, 3.595187058905424*^9}, {
3.5951875882147713`*^9, 3.595187675084825*^9}, 3.595187861555567*^9, {
3.5951952793985577`*^9, 3.595195310428541*^9}, {3.5951953462122297`*^9,
3.595195385765233*^9}, 3.595196791346478*^9, {3.5951975263674183`*^9,
3.5951975326481113`*^9}, 3.5951980620289783`*^9, {3.595198120857519*^9,
3.595198176392035*^9}, {3.5952017899681053`*^9, 3.595201895037966*^9}, {
3.595202067001499*^9, 3.595202112626268*^9}, {3.595202830522341*^9,
3.5952028318829203`*^9}}],
Cell[BoxData[
RowBox[{"Manipulate", "[", "\[IndentingNewLine]",
RowBox[{
RowBox[{"With", "[",
RowBox[{
RowBox[{"{",
RowBox[{"s3", "=",
RowBox[{"s2", "[",
RowBox[{
RowBox[{"Hmolar", "[",
RowBox[{"p", "[",
RowBox[{"[", "1", "]"}], "]"}], "]"}], ",",
RowBox[{"CO2molarFromMillimetresHg", "[", "initialCO2mmHg", "]"}],
",",
RowBox[{
RowBox[{"p", "[",
RowBox[{"[", "2", "]"}], "]"}], "/", "1000"}], ",", "co2source",
",", "co2sink", ",", "protonSource", ",", "timeSpan"}], "]"}]}],
"}"}], ",", "\[IndentingNewLine]", "\[IndentingNewLine]",
RowBox[{"TableForm", "[",
RowBox[{"{", "\[IndentingNewLine]",
RowBox[{
RowBox[{"Show", "[",
RowBox[{"contourPlot1", ",",
RowBox[{"ParametricPlot", "[",
RowBox[{
RowBox[{"Evaluate", "[",
RowBox[{
RowBox[{"{",
RowBox[{
RowBox[{"-",
RowBox[{"Log10", "[",
RowBox[{"H", "[", "t", "]"}], "]"}]}], ",",
RowBox[{"1000", " ",
RowBox[{"HCO3", "[", "t", "]"}]}]}], "}"}], "/.", "s3"}],
"]"}], ",",
RowBox[{"{",
RowBox[{"t", ",", "0", ",", "timeSpan"}], "}"}], ",",
RowBox[{"PlotRange", "\[Rule]",
RowBox[{"{",
RowBox[{
RowBox[{"{",
RowBox[{"6.8", ",", "8.0"}], "}"}], ",",
RowBox[{"{",
RowBox[{"0", ",", "100"}], "}"}]}], "}"}]}], ",",
RowBox[{"AspectRatio", "\[Rule]", "1"}], ",",
"\[IndentingNewLine]",
RowBox[{"ColorFunction", "\[Rule]",
RowBox[{"(",
RowBox[{
RowBox[{
RowBox[{"ColorData", "[", "\"\<Rainbow\>\"", "]"}], "[", "#3",
"]"}], "&"}], ")"}]}], ",",
RowBox[{"MaxRecursion", "\[Rule]", "0"}], ",",
RowBox[{"PlotStyle", "\[Rule]", "Thick"}]}], "]"}]}],
"\[IndentingNewLine]", "]"}], ",", "\[IndentingNewLine]",
RowBox[{"Plot", "[",
RowBox[{
RowBox[{"Evaluate", "[",
RowBox[{
RowBox[{"{",
RowBox[{"-",
RowBox[{"Log10", "[",
RowBox[{"H", "[", "t", "]"}], "]"}]}], "}"}], "/.", "s3"}],
"]"}], ",",
RowBox[{"{",
RowBox[{"t", ",", "0", ",", "timeSpan"}], "}"}], ",",
RowBox[{"PlotRange", "\[Rule]",
RowBox[{"{",
RowBox[{
RowBox[{"{",
RowBox[{"0", ",", "timeSpan"}], "}"}], ",",
RowBox[{"{",
RowBox[{"6.8", ",", "8.0"}], "}"}]}], "}"}]}]}], "]"}], ",",
"\[IndentingNewLine]",
RowBox[{"Plot", "[",
RowBox[{
RowBox[{"Evaluate", "[",
RowBox[{
RowBox[{"{", " ",
RowBox[{"1000",
RowBox[{
RowBox[{"CO2", "[", "t", "]"}], "/",
"co2SolubilityMilliMolarPerMmhg"}]}], "}"}], "/.", "s3"}],
"]"}], ",",
RowBox[{"{",
RowBox[{"t", ",", "0", ",", "timeSpan"}], "}"}], ",",
RowBox[{"PlotRange", "\[Rule]",
RowBox[{"{",
RowBox[{
RowBox[{"{",
RowBox[{"0", ",", "timeSpan"}], "}"}], ",",
RowBox[{"{",
RowBox[{"0", ",", "120"}], "}"}]}], "}"}]}]}], "]"}], ",",
"\[IndentingNewLine]",
RowBox[{"Plot", "[",
RowBox[{
RowBox[{"Evaluate", "[",
RowBox[{
RowBox[{"{",
RowBox[{"1000", " ",
RowBox[{"HCO3", "[", "t", "]"}]}], "}"}], "/.", "s3"}], "]"}],
",",
RowBox[{"{",
RowBox[{"t", ",", "0", ",", "timeSpan"}], "}"}], ",",
RowBox[{"PlotRange", "\[Rule]",
RowBox[{"{",
RowBox[{
RowBox[{"{",
RowBox[{"0", ",", "timeSpan"}], "}"}], ",",
RowBox[{"{",
RowBox[{"0", ",", "100"}], "}"}]}], "}"}]}]}], "]"}], ",",
"\[IndentingNewLine]",
RowBox[{
RowBox[{"{", "\[IndentingNewLine]",
RowBox[{
RowBox[{"-",
RowBox[{"Log10", "[",
RowBox[{"H", "[", "timeSpan", "]"}], "]"}]}], ",",
"\[IndentingNewLine]",
RowBox[{"1000",
RowBox[{"HCO3", "[", "timeSpan", "]"}]}]}], "\[IndentingNewLine]",
"}"}], "/.", "s3"}], ",", "\[IndentingNewLine]", "p"}],
"\[IndentingNewLine]", "}"}], "]"}]}], "\[IndentingNewLine]", "]"}],
",", "\[IndentingNewLine]",
RowBox[{"{",
RowBox[{
RowBox[{"{",
RowBox[{"p", ",", " ",
RowBox[{"{",
RowBox[{"7.4", ",", "23"}], "}"}]}], "}"}], ",", " ", "Locator"}],
"}"}], ",", "\[IndentingNewLine]",
RowBox[{"{",
RowBox[{
RowBox[{"{",
RowBox[{"initialCO2mmHg", ",", "40"}], "}"}], ",", " ", "20", ",", " ",
"80"}], "}"}], ",", "\[IndentingNewLine]",
RowBox[{"{",
RowBox[{"co2source", ",", "0", ",",
RowBox[{"10", " ",
SuperscriptBox["10",
RowBox[{"-", "6"}]]}]}], "}"}], ",", "\[IndentingNewLine]",
RowBox[{"{",
RowBox[{"co2sink", ",", "0", ",",
RowBox[{"10", " ",
SuperscriptBox["10",
RowBox[{"-", "6"}]]}]}], "}"}], ",", "\[IndentingNewLine]",
RowBox[{"{",
RowBox[{"protonSource", ",", "0", ",",
RowBox[{"2", " ",
SuperscriptBox["10",
RowBox[{"-", "9"}]]}]}], "}"}], ",", "\[IndentingNewLine]",
RowBox[{"{",
RowBox[{"timeSpan", ",", " ", "100", ",", "1000"}], "}"}], ",",
"\[IndentingNewLine]",
RowBox[{"SaveDefinitions", "\[Rule]", "True"}]}], "\[IndentingNewLine]",
"]"}]], "Input",
CellChangeTimes->{{3.5951100561015167`*^9, 3.595110109951613*^9}, {
3.595110234529901*^9, 3.595110285353689*^9}, {3.595110885327067*^9,
3.59511089952022*^9}, {3.595110968925613*^9, 3.5951109724845743`*^9}, {
3.595111238382983*^9, 3.5951112573599854`*^9}, {3.595111532497603*^9,
3.5951115445638227`*^9}, {3.595111617736834*^9, 3.595111618551908*^9}, {
3.595111703259441*^9, 3.595111723755012*^9}, 3.59511182987678*^9, {
3.595111878344162*^9, 3.595111892097144*^9}, {3.595112015885467*^9,
3.595112072733914*^9}, {3.595112227606407*^9, 3.595112228350016*^9}, {
3.5951122713045797`*^9, 3.595112337876027*^9}, {3.5951123761647177`*^9,
3.595112407603476*^9}, {3.595112500096807*^9, 3.595112500848219*^9}, {
3.5951868754099483`*^9, 3.595186877957781*^9}, {3.5951873593232327`*^9,
3.595187395202198*^9}, {3.59519550250416*^9, 3.595195553927761*^9}, {
3.595196210376645*^9, 3.595196218195732*^9}, {3.595196250780205*^9,
3.59519626126705*^9}, {3.595196325596848*^9, 3.595196326980348*^9},
3.595196817662417*^9, {3.595197519544579*^9, 3.595197520405931*^9}, {
3.595198559994164*^9, 3.5951985685511427`*^9}, {3.5952019620736322`*^9,
3.595201984273303*^9}, {3.5952022787131767`*^9, 3.5952022829774113`*^9}, {
3.595202840131628*^9, 3.595202841404508*^9}}],
Cell[BoxData[
RowBox[{
RowBox[{
RowBox[{
RowBox[{"parametricPlot", "[",
RowBox[{"sol_", ",", " ", "timeSpan_"}], "]"}], ":=",
"\[IndentingNewLine]",
RowBox[{"ParametricPlot3D", "[", "\[IndentingNewLine]",
RowBox[{
RowBox[{"Evaluate", "[",
RowBox[{
RowBox[{"{",
RowBox[{
RowBox[{"-",
RowBox[{"Log10", "[",
RowBox[{"H", "[", "t", "]"}], "]"}]}], ",",
RowBox[{"1000",
RowBox[{"HCO3", "[", "t", "]"}]}], ",",
RowBox[{"1000",
RowBox[{
RowBox[{"CO2", "[", "t", "]"}], "/",
"co2SolubilityMilliMolarPerMmhg"}]}]}], "}"}], "/.", "sol"}],
"]"}], ",", "\[IndentingNewLine]",
RowBox[{"{",
RowBox[{"t", ",", "0", ",", "timeSpan"}], "}"}], ",",
"\[IndentingNewLine]",
RowBox[{"ColorFunction", "\[Rule]",
RowBox[{"(",
RowBox[{
RowBox[{
RowBox[{"ColorData", "[", "\"\<Rainbow\>\"", "]"}], "[",
RowBox[{"1", "-", "#3"}], "]"}], "&"}], ")"}]}], ",",
"\[IndentingNewLine]",
RowBox[{"MaxRecursion", "\[Rule]", "0"}], ",", "\[IndentingNewLine]",
RowBox[{"PlotStyle", "\[Rule]", "Thick"}], ",", "\[IndentingNewLine]",
RowBox[{"BoxRatios", "\[Rule]",
RowBox[{"{",
RowBox[{"1", ",", "1", ",", "1"}], "}"}]}], ",",
"\[IndentingNewLine]",
RowBox[{"PlotRange", "\[Rule]",
RowBox[{"{",
RowBox[{
RowBox[{"{",
RowBox[{"6.8", ",", "8"}], "}"}], ",",
RowBox[{"{",
RowBox[{"0", ",", "100"}], "}"}], ",",
RowBox[{"{",
RowBox[{"0", ",", "400"}], "}"}]}], "}"}]}], ",",
"\[IndentingNewLine]",
RowBox[{"ImageSize", "\[Rule]", "Full"}]}], "\[IndentingNewLine]",
"]"}]}], ";"}], "\[IndentingNewLine]"}]], "Input",
CellChangeTimes->{{3.595199056447895*^9, 3.5951992534259367`*^9}, {
3.595199288528536*^9, 3.595199337928665*^9}, {3.595199433614749*^9,
3.5951994655006523`*^9}, {3.595200118113706*^9, 3.595200205723168*^9}, {
3.595200240621138*^9, 3.595200280195006*^9}, {3.595200330728726*^9,
3.5952003398330708`*^9}, {3.595200463679451*^9, 3.5952004650576763`*^9}, {
3.595201088338874*^9, 3.595201122368269*^9}}],
Cell[BoxData[
RowBox[{"Manipulate", "[", "\[IndentingNewLine]",
RowBox[{
RowBox[{"With", "[",
RowBox[{
RowBox[{"{",
RowBox[{"s3", "=",
RowBox[{"s2", "[",
RowBox[{
RowBox[{"Hmolar", "[", "initialPh", "]"}], ",",
RowBox[{"CO2molarFromMillimetresHg", "[", "initialCO2mmHg", "]"}],
",",
RowBox[{"initialHCO3milliMolar", "/", "1000"}], ",", "co2source",
",", "co2sink", ",", "protonSource", ",", "timeSpan"}], "]"}]}],
"}"}], ",", "\[IndentingNewLine]",
RowBox[{"Show", "[",
RowBox[{"plot3d1", ",",
RowBox[{"parametricPlot", "[",
RowBox[{"s3", ",", "timeSpan"}], "]"}]}], "]"}]}],
"\[IndentingNewLine]", "]"}], ",", "\[IndentingNewLine]",
RowBox[{"{",
RowBox[{
RowBox[{"{",
RowBox[{"initialPh", ",", "7.7"}], "}"}], ",", " ", "6.8", ",", " ",
"7.8"}], "}"}], ",", "\[IndentingNewLine]",
RowBox[{"{",
RowBox[{
RowBox[{"{",
RowBox[{"initialCO2mmHg", ",", "40"}], "}"}], ",", " ", "20", ",", " ",
"400"}], "}"}], ",", "\[IndentingNewLine]",
RowBox[{"{",
RowBox[{
RowBox[{"{",
RowBox[{"initialHCO3milliMolar", ",",
RowBox[{"1000", "initialHCO3molar"}]}], "}"}], ",", " ", "0", ",", " ",
"100"}], "}"}], ",", "\[IndentingNewLine]",
RowBox[{"{",
RowBox[{"co2source", ",", "0", ",",
RowBox[{"10", " ",
SuperscriptBox["10",
RowBox[{"-", "6"}]]}]}], "}"}], ",", "\[IndentingNewLine]",
RowBox[{"{",
RowBox[{"co2sink", ",", "0", ",",
RowBox[{"10", " ",
SuperscriptBox["10",
RowBox[{"-", "6"}]]}]}], "}"}], ",", "\[IndentingNewLine]",
RowBox[{"{",
RowBox[{"protonSource", ",", "0", ",",
RowBox[{"2", " ",
SuperscriptBox["10",
RowBox[{"-", "9"}]]}]}], "}"}], ",", "\[IndentingNewLine]",
RowBox[{"{",
RowBox[{"timeSpan", ",", " ", "100", ",", "1000"}], "}"}], ",",
"\[IndentingNewLine]",
RowBox[{"ContentSize", "\[Rule]", "400"}], ",", "\[IndentingNewLine]",
RowBox[{"SaveDefinitions", "\[Rule]", "True"}]}], "\[IndentingNewLine]",
"]"}]], "Input",
CellChangeTimes->{{3.5951871625592527`*^9, 3.595187192257338*^9}, {
3.595187234611184*^9, 3.595187310140334*^9}, 3.5951874424508667`*^9, {
3.595195650428379*^9, 3.5951957452897243`*^9}, {3.595196336154867*^9,
3.595196341745872*^9}, 3.595196411003066*^9, {3.595196453643653*^9,
3.5951964611612062`*^9}, {3.595196542463222*^9, 3.5951965487907047`*^9},
3.595196826109803*^9, {3.595197183566968*^9, 3.5951971848513603`*^9}, {
3.595197220503737*^9, 3.59519723341595*^9}, {3.595197538927472*^9,
3.5951975392061443`*^9}, {3.595198774306444*^9, 3.595198790857052*^9}, {
3.5951988340813837`*^9, 3.5951988401910152`*^9}, {3.5952003724791393`*^9,
3.5952004080929728`*^9}, {3.595200573705496*^9, 3.5952005741339808`*^9}, {
3.595200940000415*^9, 3.5952010066749973`*^9}, {3.595202000190833*^9,
3.595202019331786*^9}, {3.595202428465337*^9, 3.595202431488326*^9}, {
3.595202848945674*^9, 3.595202850536489*^9}}]
},
WindowSize->{1440, 852},
WindowMargins->{{0, Automatic}, {Automatic, 0}},
FrontEndVersion->"9.0 for Mac OS X x86 (32-bit, 64-bit Kernel) (January 25, \
2013)",
StyleDefinitions->"Default.nb"
]
(* End of Notebook Content *)
(* Internal cache information *)
(*CellTagsOutline
CellTagsIndex->{}
*)
(*CellTagsIndex
CellTagsIndex->{}
*)
(*NotebookFileOutline
Notebook[{
Cell[557, 20, 143, 3, 28, "Input"],
Cell[703, 25, 504, 11, 33, "Input"],
Cell[1210, 38, 149, 3, 28, "Input"],
Cell[1362, 43, 313, 5, 28, "Input"],
Cell[1678, 50, 797, 15, 49, "Input"],
Cell[2478, 67, 334, 7, 51, "Input"],
Cell[2815, 76, 147, 3, 28, "Input"],
Cell[2965, 81, 398, 8, 32, "Input"],
Cell[3366, 91, 246, 6, 28, "Input"],
Cell[3615, 99, 423, 11, 50, "Input"],
Cell[4041, 112, 234, 5, 28, "Input"],
Cell[4278, 119, 819, 18, 53, "Input"],
Cell[5100, 139, 187, 4, 28, "Input"],
Cell[5290, 145, 413, 9, 49, "Input"],
Cell[5706, 156, 241, 6, 28, "Input"],
Cell[5950, 164, 1121, 23, 63, "Input"],
Cell[7074, 189, 1553, 33, 131, "Input"],
Cell[8630, 224, 654, 17, 80, "Input"],
Cell[9287, 243, 3342, 72, 182, "Input"],
Cell[12632, 317, 7713, 178, 429, "Input"],
Cell[20348, 497, 7251, 174, 463, "Input"],
Cell[27602, 673, 2297, 56, 216, "Input"],
Cell[29902, 731, 3105, 69, 276, "Input"]
}
]
*)
(* End of internal cache information *)